﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="EBooks.ascx.cs" Inherits="controls_admin_EBooks" %>
<!-- table -->
<script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script src="../Scripts/jquery.tablednd_0_5.js" type="text/javascript"></script>
<script type="text/javascript">
    var variable = "0";
    var m_id = <%=m_id%>;
    var j = jQuery.noConflict();
    j(document).ready(function () {
        j('#table-3').tableDnD({
            onDrop: function (table, row) {
                variable = j.tableDnD.serialize();
            }
        });
        j("#<%=btnDel.ClientID%>").click(function () {
            var index = "";
            j("table input[type=checkbox].item").each(function () {
                var checked = j(this).attr("checked");
                if (checked) {
                    index = index + j(this).attr("value") + ";";
                }
            });
            j("#<%=hdfCheck.ClientID%>").val(index);
            if(index == "") return false;
            else return true;            
        });
        j("#<%=update.ClientID%>").click(function () {
            if (variable == "0")
                return false;
            j.ajax({
                type: "POST",
                url: "../services/AdminServices.asmx/orderebook",
                data: "{'id':'&" + variable + "','mid':'" + m_id + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                beforeSend: function () {
                    j("#<%=divMessage.ClientID %>").html("");
                },
                success: function (message) {
                    if (message.d == false) {
                        j("#<%=divMessage.ClientID %>").html("<div id='message-error' class='message message-error'><div class='image'><img src='../resources/images/icons/error.png' alt='Error' height='32' /></div><div class='text'><h6>Lỗi</h6><span>Chưa thực hiện được!</span></div><div class='dismiss'><a href='#message-error'></a></div></div>");
                    }
                    else {
                        j("#<%=divMessage.ClientID %>").html("<div id='message-success' class='message message-success'><div class='image'><img src='../resources/images/icons/success.png' alt='Success' height='32' /></div><div class='text'><h6>Thông Báo</h6><span>Cập nhật thành công !</span></div><div class='dismiss'><a href='#message-success'></a></div></div>");
                    }
                },
                error: function (errormessage) {
                    j("#<%=divMessage.ClientID %>").html("<div id='message-error' class='message message-error'><div class='image'><img src='../resources/images/icons/error.png' alt='Error' height='32' /></div><div class='text'><h6>Lỗi</h6><span>Chưa thực hiện được!</span></div><div class='dismiss'><a href='#message-error'></a></div></div>");
                }
            });
        });
    });
</script>
<div class="box">
    <!-- box / title -->
    <div class="title">
        <h5 id="title" runat="server">
            Danh Sách Ebooks</h5>
        <div class="search">
            <div class="input">
                <input id="txtSearch" runat="server" style="width: 200px" value="Hãy nhập từ khóa !"
                    onclick='if(this.value=="Hãy nhập từ khóa !")this.value=""' onblur='if(this.value=="")this.value="Hãy nhập từ khóa !"' />
            </div>
            <div class="button">
                <asp:Button ID="btnSearch" runat="server" Text="Tìm kiếm" OnClick="btnSearch_Click" />
            </div>
        </div>
    </div>
    <div id="divMessage" runat="server">
    </div>
    <div id="divResult" class="result" runat="server">
    </div>
    <div class="first-action">
        <asp:DropDownList AutoPostBack="true" CssClass="select" ID="ddlCategory" runat="server"
            OnSelectedIndexChanged="ddlCategory_SelectedIndexChanged" />
        <asp:HiddenField ID="hdfCheck" runat="server" />
    </div>
    <!-- end box / title -->
    <div class="table">
        <table id="table-3">
            <thead>
                <tr>
                    <th>
                        STT
                    </th>
                    <th>
                        Ảnh hiển thị
                    </th>
                    <th>
                        Tiêu đề
                    </th>
                    <th>
                        Ngày đăng
                    </th>
                    <th>
                        Hiển thị
                    </th>
                    <th>
                        Sửa
                    </th>
                    <th class="selected last">
                        <input type="checkbox" class="checkall" />
                    </th>
                </tr>
            </thead>
            <tbody>
                <asp:Repeater ID="rptNews" runat="server" OnItemCommand="rptNews_ItemCommand" OnItemDataBound="rptNews_ItemDataBound">
                    <ItemTemplate>
                        <tr id='<%#Eval("EBOOK_ID") %>' style="cursor: move">
                            <td>
                                <%#(Container.ItemIndex+1)+(base.Cur_page-1)*base.Page_size %>
                                <asp:HiddenField ID="hdfID" runat="server" Value='<%#Eval("EBOOK_ID")%>' />
                            </td>
                            <td align="center">
                                <img src='../upload/ebooks/<%#Eval("THUMB_IMG") %>' alt='<%#Eval("FULL_BOOK_TITLE") %>'
                                    title='<%#Eval("FULL_BOOK_TITLE") %>' height="100" />
                            </td>
                            <td align="center">
                                <%#Eval("FULL_BOOK_TITLE")%>
                            </td>
                            <td align="center">
                                <%#LibraryO2S.O2S_DateTime.dd_MM_yyyy(Convert.ToDateTime(Eval("CREATED_DATE")))%>
                            </td>
                            <td align="center">
                                <asp:Button runat="server" ID="btnDisplay" CssClass="icon-32-checking" CommandName="Display"
                                    CommandArgument='<%#Eval("IS_DISPLAY_ON_HOME_PAGE")%>' BackColor="Transparent"
                                    BorderStyle="None" />
                            </td>
                            <td align="center">
                                <%if (Request["t"] != null)
                                  { %>
                                <a href='<%#"default.aspx?module=ebooksedit&t=1&m_id="+ m_id +"&e_id="+Eval("EBOOK_ID")%>'
                                    title="Chỉnh Sửa">
                                    <img src="../Resources/icons/16x16/edit.png" class="icon-32-edit" />
                                </a>
                                <%}
                                  else
                                  {%>
                                <a href='<%#"default.aspx?module=ebooksedit&m_id="+ m_id +"&e_id="+Eval("EBOOK_ID")%>'
                                    title="Chỉnh Sửa">
                                    <img src="../Resources/icons/16x16/edit.png" class="icon-32-edit" />
                                </a>
                                <%} %>
                            </td>
                            <td align="center" class="last">
                                <input type="checkbox" value='<%#Eval("EBOOK_ID")%>' class="item" />
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </tbody>
        </table>
        <div class="pagination pagination-left last">
            <div class="pagerContainer" id="pagerContainer" runat="server">
            </div>
        </div>
        <div class="action">
            <div class="button">
                <asp:Button ID="btnNew" runat="server" Text="Thêm Mới" OnClick="btnNew_Click" />
                <input type="button" value="Cập nhật thứ tự" id="update" runat="server" />
                <asp:Button ID="btnDel" runat="server" Text="Xóa" OnClick="btnDel_Click" />
            </div>
        </div>
    </div>
</div>
<!-- end table -->
